<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
          
              
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>用户登录</legend>
</fieldset>
 
<form class="layui-form">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="login">登录</button>
      <button type="reset" class="layui-btn layui-btn-primary">注册</button>
    </div>
  </div>
</form>

          
<script src="/static/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['form'], function(){
  var form = layui.form;
  var $ = layui.$;
  
  form.on('submit(login)',function(data){
	  $.ajax({
		  url:'/login/loginInto',
		  method:'post',
		  data:data.field,
		  dataType:'JSON',
		  success:function(res){
			  if(res.code==0){
				  layer.msg('登录成功',{
					  icon:1,
					  time:1000
				  },function(){
					  window.location.href="/user/list";
					  layer.closeAll();
				  });
				  
			  }else{
				  layer.msg(res.msg,{
					  icon:2,
					  time:1500
				  },function(){
					  
				  });
			  }
			 
		  }
	  });
	  return false;
  });
  
  
});
</script>

</body>
</html>
